package constants;

import java.lang.reflect.Field;
import java.util.Properties;

/**
 * 
 * @author JohnZantey
 * <p>
 * A class to define constants to eliminate any hard coding through out the system.
 * </p>
 * <p>
 * Variables declared can be overridden with -D VM arguments (a.k.a. Dargs) to allow for run time qualification.
 * </p>
 * <p>
 * Only variables allowed to be set via Dargs defined here.
 * </p>
 */
public class SystemConstants {
	/**
	 * location of source data XML file
	 */
	public static String xmlFilePath = "./RiftData/data/Rift_Achievements_2011-02-23.xml";
	/**
	 * location of source data XSD file
	 */	
	public static String xsdFilePath = "./RiftData/data/Rift_Achievements_2011-02-23.xsd";
	/**
	 * location to ImageMagic to use to convert .DDS asset files supplied by TRION
	 */
	public static String imageConvertExecutable = "C:/Program Files/ImageMagick-6.6.7-Q16/convert.exe";
	/**
	 * ImageMagic conversion format
	 */
	public static String imageFormat = "png";
	/**
	 * ImageMagic conversion depth
	 */
	public static String imageDepth = "8";	
	
	
	static {
		Properties systemProperties = System.getProperties();
		
		Field[] fields = SystemConstants.class.getFields();
		for (int i = 0; i < fields.length; i++) {
			String  prop = (String) systemProperties.get(fields[i].getName());
			if (prop != null) {
				if (-1==fields[i].getName().indexOf("PASSWORD")){
					System.out.println("Found property: "+fields[i].getName() + " value " + prop);
				} else {
					System.out.println("Found property: "+fields[i].getName() + " value xxxx");
				}
				try {
					fields[i].set(null, prop);
				} catch (IllegalArgumentException e) {
					e.printStackTrace();
					throw new RuntimeException(e);
				} catch (IllegalAccessException e) {
					e.printStackTrace();
					throw new RuntimeException(e);
				}
			}	else
				System.out.println("Did not find property: "+fields[i].getName());
		}
	}	
	
}
